package com.controller.qd;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.common.ajax.AjaxRes;
import com.common.utils.base.UuidUtil;
import com.controller.base.BaseController;
import com.entity.Product;
import com.service.ProductService;

@Controller
@RequestMapping("/cpsc/")
public class CpscController extends BaseController<Object>{

	@Autowired
	private ProductService proservice;
	/**
	 * 添加产品信息
	 * @return
	 */
	@RequestMapping("/insert")
	@ResponseBody
	public AjaxRes insert(Product pro,String time,String publisherSession){
		SimpleDateFormat format =   new SimpleDateFormat( "yyyy-MM-dd" );
		Date date = null;
		try {
			date = format.parse(time);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		AjaxRes res=new AjaxRes(); 
		pro.setId(UuidUtil.get32UUID());
		pro.setImage("");
		pro.setTimeP(date);
		pro.setAuditorTime(new Date());
		pro.setReason("无驳回原因");
		pro.setReleaseTime(new Date());
		pro.setState("正常");
		pro.setClassification("无");
		pro.setPublisher(publisherSession);
		Integer a =	proservice.insert(pro);
		if(a==0){
			res.setResMsg("添加失败");
		}else{
			res.setResMsg("添加成功");
		}
		return res;
	}
}
